package com.mz.ieann.aide.app

import android.app.Application
import android.net.http.HttpResponseCache
import com.bumptech.glide.Glide
import com.mz.ieann.aide.utils.AppUtil
import com.mz.ieann.aide.utils.FlutterHelper
import java.io.File

/**
 * <p>------------------------------------------------------
 * <p> Copyright (C) 2021 zhangmz, All rights reserved.
 * <p> If there is technical discussion, you can contact zhangmz90@foxmail.com
 * <p>------------------------------------------------------
 * <p> des
 * <p>
 *
 * @author Created by Administrator
 * @date on 2021 2021/11/14 11:54
 */
class BaseApplication : Application() {

    private val appUtil = AppUtil()

    override fun onCreate() {
        appUtil.initApp(this)
        super.onCreate()
        val cacheDir = File(applicationContext.cacheDir, "http")
        HttpResponseCache.install(cacheDir, 1024 * 1024 * 128)

        FlutterHelper.initEngineCache(this)
        FlutterHelper.initFlutterBoost(this)

    }

    override fun onTerminate() {
        super.onTerminate()
        appUtil.onTerminate(this)
        Glide.get(this).clearMemory()
    }

    override fun onLowMemory() {
        super.onLowMemory()
        Glide.get(this).onLowMemory()
    }

    override fun onTrimMemory(level: Int) {
        super.onTrimMemory(level)
        Glide.get(this).onTrimMemory(level)
    }

}